/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-11-29 11:31:02
 * @LastEditors: huangtianyang
 * @LastEditTime: 2024-04-23 18:59:38
 * @FilePath: \cxl-driving-training\src\apis\siteConfig\index.ts
 */
import axios from '../../axios/index'
import { classTagListInterface } from '../class'

export interface siteConfigOperationInterface {
    id?: string
    schoolId?: string
    siteTwoId?: string //科目二场地id
    siteThreeIdList?: string[] //科目三场地id集合
}

export const siteConfigAdd = (data: siteConfigOperationInterface) => {
    return axios({
        method: 'post',
        url: '/api/system/trainSiteConfig/add',
        data
    })
}

export const siteConfigEdit = (data: siteConfigOperationInterface) => {
    return axios({
        method: 'post',
        url: '/api/system/trainSiteConfig/edit',
        data
    })
}

export const siteConfigDetailed = (id: string) => {
    return axios({
        method: 'get',
        url: '/api/system/trainSiteConfig/detailById',
        params: { id }
    })
}

export interface siteConfigListInterface {
    current?: number
    size?: number
    disable?: number //0.可用；1.禁用
    schoolName?: string
    siteThreeName?: string
    siteTwoName?: string
}

export const siteConfigList = (params: siteConfigListInterface) => {
    return axios({
        method: 'get',
        url: '/api/system/trainSiteConfig/pageList',
        params
    })
}

/**
 * 训练场地禁用启用
 * @param disable  0.可用；1.禁用
 * @param id
 * @returns
 */
export const siteConfigDisable = (disable: number, id: string) => {
    return axios({
        method: 'post',
        url: '/api/system/trainSiteConfig/enable',
        data: { disable, id }
    })
}

export interface siteListInterface {
    current?: number
    size?: number
    ownFlag?: number //是否自有(0.否；1.是)
    schoolId?: string //
    siteCategory?: number //场地种类（2.科目二；3.科目三）
    trainSiteName?: string //驾校全称
    disable?: number
}

//场地列表
export const siteList = (params: siteListInterface) => {
    return axios({
        method: 'get',
        url: '/api/system/trainSite/manage/getPageList',
        params
    })
}

//单个场地信息
export const siteDetailedById = (configId: string) => {
    return axios({
        method: 'get',
        url: '/api/system/trainSite/manage/getDetailById',
        params: { configId }
    })
}

export interface siteInterface {
    schoolId?: string
    trainSiteThree: {
        addressDetail?: string
        id?: string
        lat?: number
        lng?: number
        name?: string
        regionId?: string
    }
    trainSiteTwo: {
        addressDetail?: string
        equipmentIntroduction?: string
        id?: string
        lat?: number
        lng?: number
        name?: string
        openHours?: string
        ownFlag?: number
        regionId?: string
        sitePic: classTagListInterface[]
        siteType?: number
        siteVideo: classTagListInterface[]
        supportFacility: string[]
    }
}

export const createSite = (data: siteInterface) => {
    return axios({
        method: 'post',
        url: '/api/system/trainSite/manage/add',
        data
    })
}
export const editSite = (data: siteInterface) => {
    return axios({
        method: 'post',
        url: '/api/system/trainSite/manage/edit',
        data
    })
}

/**
 * 训练场地禁用启用
 * @param disable  0.可用；1.禁用
 * @param id
 * @returns
 */
export const siteDisable = (disable: number, id: string) => {
    return axios({
        method: 'post',
        url: '/api/system/trainSite/manage/updateDisable',
        data: { disable, id }
    })
}
